package com.fanxuankai.boot.upload.autoconfigure;

import com.fanxuankai.boot.upload.Uploader;
import com.fanxuankai.boot.upload.mapper.JobMapper;
import com.fanxuankai.commons.util.concurrent.ScheduledThreadPool;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

import java.util.concurrent.ScheduledThreadPoolExecutor;

/**
 * @author fanxuankai
 */
@EnableConfigurationProperties({UploadProperties.class})
@ConditionalOnWebApplication
@ComponentScan(basePackageClasses = {Uploader.class})
@MapperScan(basePackageClasses = JobMapper.class)
public class UploadAutoConfiguration {
    @Bean
    @ConditionalOnMissingBean
    public ScheduledThreadPoolExecutor scheduledThreadPoolExecutor() {
        return ScheduledThreadPool.INSTANCE.getExecutor();
    }
}
